<?php
include_once('common/header.php');	
$intPage			= $objRequest->getParam('page', 1);
$intFilter			= $objRequest->getParam('filter', -1);
$strKeyword			= $objRequest->getParam('keyword', null);
$strDateFrom 		= $objRequest->getParam('startdate', null);
$strDateTo			= $objRequest->getParam('enddate', null);
$arrSubCategoryId 	= $objRequest->getParam('se_cate', null);
if($intFilter > -1 || (isset($strKeyword) && $strKeyword != '') || (isset($strDateFrom) &&  $strDateFrom != '') || (isset($strDateTo) && $strDataTo != '') || isset($arrSubCategoryId)) {	
	$objNews 	= new News();	
	$intTotal	= 0;
	$intLimit	= NEWS_LIMIT;
	if(!isset($intAjax)) {
		$arrCate	= array();
		if($arrSubCategoryId) {
			foreach($arrSubCategoryId as $value) {
				$arrCate[$value] = $value;
			}
		}	
		$strSubCate	= Vfriend_Function::convertArrToStr($arrSubCategoryId);	
	} else {
		$strSubCate	= (string)$arrSubCategoryId;
	}
	$intOffset	= ($intPage - 1) * $intLimit;
	$arrResult	= $objNews->getSearch($intFilter,$strKeyword,$strSubCate,Vfriend_Function::convertStrToDate($strDateFrom),Vfriend_Function::convertStrToDate($strDateTo),$intOffset,$intLimit,$intTotal);
	$this->view->arrList		= $arrResult;
	if(!isset($intAjax)) {
		$this->view->strKeyword	= $strKeyword;	
		$this->view->startdate	= $strDateFrom;
		$this->view->enddate	= $strDateTo;	
		$this->view->arrCate	= $arrCate;	
	}
	$this->view->act		= 1;
	$this->view->intTotalPage	= ceil($intTotal / $intLimit);
	$this->view->intPage 		= $intPage;		
}	
if(!isset($intAjax)) {
	$this->view->arrFilter 	= $arrFilter;	
	$this->view->intFilter	= $intFilter;
}
?>
